{"ast":null,"code":"import _slicedToArray from \"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/slicedToArray.js\";\nimport _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport { unstable_useId as useId, unstable_useForkRef as useForkRef } from '@mui/utils';\nimport { MenuUnstyledContext } from '../MenuUnstyled';\nimport { useButton } from '../ButtonUnstyled';\nexport default function useMenuItem(props) {\n  var _itemState$disabled;\n  var _props$disabled = props.disabled,\n    disabled = _props$disabled === void 0 ? false : _props$disabled,\n    ref = props.ref,\n    label = props.label;\n  var id = useId();\n  var menuContext = React.useContext(MenuUnstyledContext);\n  var itemRef = React.useRef(null);\n  var handleRef = useForkRef(itemRef, ref);\n  if (menuContext === null) {\n    throw new Error('MenuItemUnstyled must be used within a MenuUnstyled');\n  }\n  var registerItem = menuContext.registerItem,\n    unregisterItem = menuContext.unregisterItem,\n    open = menuContext.open;\n  React.useEffect(function () {\n    if (id === undefined) {\n      return undefined;\n    }\n    registerItem(id, {\n      disabled: disabled,\n      id: id,\n      ref: itemRef,\n      label: label\n    });\n    return function () {\n      return unregisterItem(id);\n    };\n  }, [id, registerItem, unregisterItem, disabled, ref, label]);\n  var _useButton = useButton({\n      disabled: disabled,\n      focusableWhenDisabled: true,\n      ref: handleRef\n    }),\n    getButtonProps = _useButton.getRootProps,\n    focusVisible = _useButton.focusVisible;\n\n  // Ensure the menu item is focused when highlighted\n  var _React$useState = React.useState(false),\n    _React$useState2 = _slicedToArray(_React$useState, 2),\n    focusRequested = _React$useState2[0],\n    requestFocus = _React$useState2[1];\n  var focusIfRequested = React.useCallback(function () {\n    if (focusRequested && itemRef.current != null) {\n      itemRef.current.focus();\n      requestFocus(false);\n    }\n  }, [focusRequested]);\n  React.useEffect(function () {\n    focusIfRequested();\n  });\n  React.useDebugValue({\n    id: id,\n    disabled: disabled,\n    label: label\n  });\n  var itemState = menuContext.getItemState(id != null ? id : '');\n  var _ref = itemState != null ? itemState : {\n      highlighted: false\n    },\n    highlighted = _ref.highlighted;\n  React.useEffect(function () {\n    requestFocus(highlighted && open);\n  }, [highlighted, open]);\n  if (id === undefined) {\n    return {\n      getRootProps: function getRootProps(other) {\n        return _extends({}, other, getButtonProps(other), {\n          role: 'menuitem'\n        });\n      },\n      disabled: false,\n      focusVisible: focusVisible\n    };\n  }\n  return {\n    getRootProps: function getRootProps(other) {\n      var optionProps = menuContext.getItemProps(id, other);\n      return _extends({}, other, getButtonProps(other), {\n        tabIndex: optionProps.tabIndex,\n        id: optionProps.id,\n        role: 'menuitem'\n      });\n    },\n    disabled: (_itemState$disabled = itemState == null ? void 0 : itemState.disabled) != null ? _itemState$disabled : false,\n    focusVisible: focusVisible\n  };\n}","map":{"version":3,"names":["_extends","React","unstable_useId","useId","unstable_useForkRef","useForkRef","MenuUnstyledContext","useButton","useMenuItem","props","_itemState$disabled","disabled","ref","label","id","menuContext","useContext","itemRef","useRef","handleRef","Error","registerItem","unregisterItem","open","useEffect","undefined","focusableWhenDisabled","getButtonProps","getRootProps","focusVisible","useState","focusRequested","requestFocus","focusIfRequested","useCallback","current","focus","useDebugValue","itemState","getItemState","highlighted","other","role","optionProps","getItemProps","tabIndex"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@mui/base/MenuItemUnstyled/useMenuItem.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport { unstable_useId as useId, unstable_useForkRef as useForkRef } from '@mui/utils';\nimport { MenuUnstyledContext } from '../MenuUnstyled';\nimport { useButton } from '../ButtonUnstyled';\nexport default function useMenuItem(props) {\n  var _itemState$disabled;\n  const {\n    disabled = false,\n    ref,\n    label\n  } = props;\n  const id = useId();\n  const menuContext = React.useContext(MenuUnstyledContext);\n  const itemRef = React.useRef(null);\n  const handleRef = useForkRef(itemRef, ref);\n  if (menuContext === null) {\n    throw new Error('MenuItemUnstyled must be used within a MenuUnstyled');\n  }\n  const {\n    registerItem,\n    unregisterItem,\n    open\n  } = menuContext;\n  React.useEffect(() => {\n    if (id === undefined) {\n      return undefined;\n    }\n    registerItem(id, {\n      disabled,\n      id,\n      ref: itemRef,\n      label\n    });\n    return () => unregisterItem(id);\n  }, [id, registerItem, unregisterItem, disabled, ref, label]);\n  const {\n    getRootProps: getButtonProps,\n    focusVisible\n  } = useButton({\n    disabled,\n    focusableWhenDisabled: true,\n    ref: handleRef\n  });\n\n  // Ensure the menu item is focused when highlighted\n  const [focusRequested, requestFocus] = React.useState(false);\n  const focusIfRequested = React.useCallback(() => {\n    if (focusRequested && itemRef.current != null) {\n      itemRef.current.focus();\n      requestFocus(false);\n    }\n  }, [focusRequested]);\n  React.useEffect(() => {\n    focusIfRequested();\n  });\n  React.useDebugValue({\n    id,\n    disabled,\n    label\n  });\n  const itemState = menuContext.getItemState(id != null ? id : '');\n  const {\n    highlighted\n  } = itemState != null ? itemState : {\n    highlighted: false\n  };\n  React.useEffect(() => {\n    requestFocus(highlighted && open);\n  }, [highlighted, open]);\n  if (id === undefined) {\n    return {\n      getRootProps: other => _extends({}, other, getButtonProps(other), {\n        role: 'menuitem'\n      }),\n      disabled: false,\n      focusVisible\n    };\n  }\n  return {\n    getRootProps: other => {\n      const optionProps = menuContext.getItemProps(id, other);\n      return _extends({}, other, getButtonProps(other), {\n        tabIndex: optionProps.tabIndex,\n        id: optionProps.id,\n        role: 'menuitem'\n      });\n    },\n    disabled: (_itemState$disabled = itemState == null ? void 0 : itemState.disabled) != null ? _itemState$disabled : false,\n    focusVisible\n  };\n}"],"mappings":";AAAA,OAAOA,QAAQ,MAAM,oCAAoC;AACzD,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,cAAc,IAAIC,KAAK,EAAEC,mBAAmB,IAAIC,UAAU,QAAQ,YAAY;AACvF,SAASC,mBAAmB,QAAQ,iBAAiB;AACrD,SAASC,SAAS,QAAQ,mBAAmB;AAC7C,eAAe,SAASC,WAAW,CAACC,KAAK,EAAE;EACzC,IAAIC,mBA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